package com.yequan.adapter;

/**
 * @author yequan
 * @date 2021/06/22 09:33
 **/
public class Test {

    public static void main(String[] args) {
        AnimalAdapter animalAdapter = new Dog();
        say(animalAdapter);
        AnimalAdapter animalAdapter2 = new Cat();
        say(animalAdapter2);
    }

    public static void say(AnimalAdapter animalAdapter){
        Object animal = animalAdapter.getAnimal();
        if (animal instanceof Dog){
            Dog dog = (Dog) animal;
            dog.w();
        } else if (animal instanceof Cat){
            Cat cat = (Cat) animal;
            cat.m();
        }
    }

}
